package com.ruoyi.livedemo.controller;

import com.ruoyi.livedemo.common.ApiResponse;
import com.ruoyi.livedemo.context.CurrentUserHolder;
import com.ruoyi.livedemo.dto.DashboardSummary;
import com.ruoyi.livedemo.dto.UserProfileView;
import com.ruoyi.livedemo.service.DashboardService;
import com.ruoyi.livedemo.service.ProfileService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/dashboard")
public class DashboardController {

    private final DashboardService dashboardService;
    private final ProfileService profileService;

    @GetMapping("/summary")
    public ApiResponse<DashboardSummary> summary() {
        Long userId = CurrentUserHolder.getUserId();
        return ApiResponse.ok(dashboardService.build(userId));
    }

    @GetMapping("/profile")
    public ApiResponse<UserProfileView> profile() {
        Long userId = CurrentUserHolder.getUserId();
        return ApiResponse.ok(profileService.loadProfile(userId));
    }
}

